var winston = require('winston');

module.exports = function(pool, req, res, next){
	var eventId = req.params.eventId;
	if(eventId){
		var queryString = 'SELECT * FROM share_access where event_id=' + eventId + ' ORDER BY id';
		pool.getConnection(function(err, connection){
			if(err){
				winston.error('DB connection error: ' + err);
				res.status(500).send('DB connection error: ' + err);
			}
			connection.query(queryString, function(err, rows){
				if(err){
					winston.error('DB query error: ' + err);
					res.status(500).send('DB query error: ' + err);
				}else{
					res.send(rows);
				}
				connection.release();
			});
		});
	}else{
		winston.error('ROUT error, can not get eventId');
		res.status(500).send('ROUT error, can not get eventId')
	}
	
}